home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 29
/
Volume 29 - JOGO DISK .iso
/
Games
/
jungle_adventure.swf
/
scripts
/
__Packages
/
GDK
/
Node.as
< prev
next >
Wrap
Text File
|
2006-11-29
|
10KB
|
397 lines
class GDK.Node
{
static var created = 0;
var className = "Node";
var uniqueID = -1;
var x = 0;
var y = 0;
var z = 0;
var isDisplayNode = false;
var angle = 0;
var renderable = true;
static var COLLISION_OK = 1;
static var COLLISION_CANCEL = 2;
static var COLLISION_SKIP_EVENT = 3;
static var collisionID = 0;
var classID = 0;
var collisionMask = 0;
var collisionOverlap = false;
var inScene = false;
var keepInScene = false;
var rogueNode = false;
var affectChildren = true;
var allowChildren = true;
var hasChildren = false;
var stopCol = false;
var editor_isItem = false;
var editor_tool = "CreateObject";
var editor_description = "Description for item";
var editor_name = "Generic Object";
var editor_args_names = [];
var editor_args_values = [];
var editor_args_types = [];
var editor_args_options = [];
var editor_args_descriptions = [];
var editor_args_mode = [];
var editor_args_component = [];
var editor_commands = [];
var editor_canChangeAsset = true;
var editor_canChangeLayer = true;
var editor_canChangeFrame = true;
var editor_nullDefaultsOnSave = true;
var editor_canRotate = false;
var editor_canScale = false;
function Node()
{
this.uniqueID = ++GDK.Node.created;
new GDK.EventSubscriber(this);
this.setRenderable(this.renderable);
this.setAffectChildren(this.affectChildren);
if(this.onAddToWorld)
{
this.addEvent("addToWorld",this.onAddToWorld,this);
}
if(this.onRemoveFromWorld)
{
this.addEvent("removeFromWorld",this.onRemoveFromWorld,this);
}
if(this.onAddToScene)
{
this.addEvent("addToScene",this.onAddToScene,this);
}
if(this.onRemoveFromScene)
{
this.addEvent("removeFromScene",this.onRemoveFromScene,this);
}
if(this.onAddDisplay)
{
this.addEvent("addDisplay",this.onAddDisplay,this);
}
if(this.onRemoveDisplay)
{
this.addEvent("removeDisplay",this.onRemoveDisplay,this);
}
}
function setAngle(angle)
{
this.angle = angle;
if(this.target)
{
this.target._rotation = angle;
}
this.sendEvent("rotate",angle);
}
function addToScene()
{
if(this.inScene)
{
return undefined;
}
this.world.addActiveObject(this);
this.inScene = true;
this.addDisplay();
this.sendEvent("addToScene");
if(this.children)
{
var _loc2_ = this.children.length;
while((_loc2_ = _loc2_ - 1) > -1)
{
this.children[_loc2_].addToScene();
}
}
}
function removeFromScene()
{
if(!this.inScene || this.keepInScene)
{
return undefined;
}
this.removeDisplay();
this.inScene = false;
this.world.removeActiveObject(this);
this.sendEvent("removeFromScene");
if(this.children)
{
var _loc2_ = this.children.length;
while((_loc2_ = _loc2_ - 1) > -1)
{
this.children[_loc2_].removeFromScene();
}
}
}
function setAffectChildren(b)
{
if(this.affectChildren == b)
{
return undefined;
}
if(this.affectChildren = b)
{
if(this.children)
{
this.onBeginParent();
}
}
else if(this.children)
{
this.onEndParent();
}
}
function addChild(child, isolated)
{
if(!this.allowChildren || child.parent == this)
{
return false;
}
child.parent.removeChild(child);
child.parent = this;
if(this.world && this.world != child.world)
{
this.world.addObject(child,true);
}
if(this.children == undefined)
{
if(this.affectChildren)
{
this.positionChanged = this.pv_positionChanged;
}
this.onBeginParent();
this.hasChildren = true;
this.children = [child];
}
else
{
this.children.push(child);
}
if(this.inScene && !isolated)
{
child.addToScene();
}
this.onAddChild(child);
return true;
}
function removeChild(child)
{
if(!this.children || child.parent != this)
{
return undefined;
}
var _loc2_ = this.children.length;
while((_loc2_ = _loc2_ - 1) > -1)
{
if(this.children[_loc2_] == child)
{
this.children.splice(_loc2_,1);
break;
}
}
child.parent = undefined;
if(!this.children.length)
{
delete this.positionChanged;
this.onEndParent();
this.hasChildren = false;
delete this.children;
}
}
function addToWorld(newWorld)
{
newWorld.addObject(this);
}
function removeFromWorld()
{
this.world.removeObject(this);
}
function detachFromParent()
{
this.parent.removeChild(this);
}
function becomeChildTo(parent)
{
parent.addChild(this);
}
function requestDisplaySpace()
{
if(!this.displayNode)
{
var _loc2_ = this.parent;
while(_loc2_)
{
if(_loc2_.isDisplayNode)
{
break;
}
_loc2_ = _loc2_.parent;
}
this.displayNode = !_loc2_ ? this.world.target : _loc2_.target;
}
var _loc3_ = undefined;
if(this.assetID != null)
{
_loc3_ = this.displayNode.attachMovie(this.assetID,"mc" + this.uniqueID,2130690045 - this.uniqueID);
}
else
{
_loc3_ = this.displayNode.createEmptyMovieClip("mc" + this.uniqueID,2130690045 - this.uniqueID);
}
return _loc3_;
}
function addDisplay()
{
if(!this.renderable || this.target)
{
return undefined;
}
this.queueForDisplay();
this.target = this.requestDisplaySpace();
this.sendEvent("addDisplay");
}
function removeDisplay()
{
this.sendEvent("removeDisplay");
this.target.swapDepths(0);
this.target.removeMovieClip();
delete this.target;
}
function setAssetID(newAssetID)
{
if(this.assetID == newAssetID)
{
return undefined;
}
if(this.inScene)
{
this.removeDisplay();
}
this.assetID = newAssetID;
if(this.inScene)
{
this.addDisplay();
}
}
function queueForDisplay()
{
if(this.renderable)
{
this.world.queueForDisplay(this);
}
}
function setRenderable(b)
{
if(b)
{
delete this.queueForDisplay;
if(this.inScene)
{
this.addDisplay();
}
}
else if(this.inScene)
{
this.removeDisplay();
}
}
function checkCollisionList(objects, flag, options, maxCol)
{
if(maxCol == null)
{
maxCol = 256;
}
if(flag == null)
{
return undefined;
}
this.stopCol = false;
var _loc3_ = 0;
var _loc6_ = undefined;
var _loc4_ = objects.length;
GDK.Node.collisionID = GDK.Node.collisionID + 1;
var _loc2_ = undefined;
while(!this.stopCol && (_loc4_ = _loc4_ - 1) > -1)
{
if(!((_loc2_ = objects[_loc4_]) != this && GDK.Node.collisionID != _loc2_.lastCollisionID && (flag & _loc2_.classID) > 0))
{
continue;
}
_loc2_.lastCollisionID = GDK.Node.collisionID;
if(_loc6_ = this.checkCollision(_loc2_))
{
_loc3_ = _loc3_ + 1;
}
switch(_loc6_)
{
case 1:
if(this.onCollision(objects[_loc4_],options) == GDK.Node.COLLISION_CANCEL)
{
return _loc3_;
}
break;
case 2:
return _loc3_;
}
}
return _loc3_;
}
function checkCollision(obj)
{
return false;
}
function moveTo(x, y, z)
{
this.moveBy(x - this.x,y - this.y,z - this.z);
}
function moveBy(x, y, z)
{
if(x || y || z)
{
this.x += x;
this.y += y;
this.z += z;
this.positionChanged(x,y,z);
}
}
function moveToGlobally(x, y, z)
{
}
function positionChanged(xShift, yShift, zShift)
{
this.onMove(xShift,yShift,zShift);
this.queueForDisplay();
}
function pv_positionChanged(xShift, yShift, zShift)
{
this.onMove(xShift,yShift,zShift);
var _loc2_ = this.children.length;
while((_loc2_ = _loc2_ - 1) > -1)
{
this.children[_loc2_].moveBy(xShift,yShift,zShift);
}
this.queueForDisplay();
}
function setDisplay()
{
this.target._x = this.x;
this.target._y = this.y;
}
function getUpdates()
{
this.world.addEvent("update",function(elapsed)
{
this.update(elapsed);
}
,this);
}
function cancelUpdates()
{
this.world.removeEvent("update",null,this);
}
function timelineUpdate()
{
this.queueForDisplay();
}
function toString()
{
return this.className + " #" + this.uniqueID + (!this.name ? "" : "(" + this.name + ")");
}
}